//
//  UITableView+EmptyData.m
//  WuShiCity
//
//  Created by chengjie on 16/7/5.
//  Copyright © 2016年 chengjie. All rights reserved.
//

#import "UITableView+EmptyData.h"
#import "PublishViewController.h"
#import <objc/runtime.h>

@implementation UITableView (EmptyData)

- (NSInteger)showMessage:(NSString *)title btnTitle:(NSString *)btnTitle byDataSourceCount:(NSInteger)count {
    
    if (count == 0) {
        
        self.backgroundView = ({
            
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight/2)];
            label.text = title;
            [self addSubview:label];
            label.textAlignment = NSTextAlignmentCenter;
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];
            [btn setTitle:btnTitle forState:UIControlStateNormal];
            [btn setFrame:CGRectMake(0, kScreenHeight/2+100, kScreenWidth, 100)];
//            [btn addTarget:self action:@selector(backBtn:) forControlEvents:UIControlEventTouchUpOutside];
            btn.titleLabel.textAlignment = NSTextAlignmentCenter;
            btn;
        });
        self.separatorStyle = UITableViewCellSeparatorStyleNone;
    } else {
        
        self.backgroundView = nil;
        self.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    }
    return count;
}

@end
